local more1__shouxia = fk.CreateSkill {
  name = "more1__shouxia",
}

Fk:loadTranslationTable{
  ["more1__shouxia"] = "守夏",
  [":more1__shouxia"] = "弃牌阶段结束时，若你没有【问计】获得的牌，你恢复Y点体力，"..
  "否则，你弃置所有【问计】获得的牌并失去等量体力然后从弃牌堆获得每种类型的牌各一张。(Y为本轮问计获得牌的数量)",

  ["$more1__shouxia1"] = "",
  ["$more1__shouxia2"] = "",
}


more1__shouxia:addEffect(fk.EventPhaseEnd, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(more1__shouxia.name) and player.phase == Player.Discard 
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if not table.find(player:getCardIds("h"),function(id)
      return Fk:getCardById(id):getMark("@@more1__wenji-inhand") > 0
    end) then 
      if not player.dead and player:isWounded() then
        room:recover { num = player:getMark("@more1__wenji-round"), skillName = more1__shouxia.name, who = player, recoverBy = player}
      end
    else
      local card = table.filter(player:getCardIds("h"),function(id)
        return Fk:getCardById(id):getMark("@@more1__wenji-inhand") > 0
      end)
      room:loseHp(player, #card, more1__shouxia.name)
      local cards = room:getCardsFromPileByRule(".|.|.|.|.|equip", 1, "discardPile")
      if #cards > 0 then
        local id = cards[1]
        local card = Fk:getCardById(id)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, more1__shouxia.name, nil, true, player)
      end

      local cards = room:getCardsFromPileByRule(".|.|.|.|.|basic", 1, "discardPile")
      if #cards > 0 then
        local id = cards[1]
        local card = Fk:getCardById(id)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, more1__shouxia.name, nil, true, player)
      end

      local cards = room:getCardsFromPileByRule(".|.|.|.|.|trick", 1, "discardPile")
      if #cards > 0 then
        local id = cards[1]
        local card = Fk:getCardById(id)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, more1__shouxia.name, nil, true, player)
      end
    end
  end,
})















return more1__shouxia
